home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DDJMAG / DDJ9203.ZIP / OOPASM.ZIP / DOSERROR.ASM < prev    next >
Assembly Source File  |  1990-07-10  |  3KB  |  130 lines

  1.     .MODEL    SMALL
  2.  
  3.     INCLUDE    equates.inc
  4.     INCLUDE    instance.inc
  5.     INCLUDE    messages.inc
  6.     INCLUDE    objects.inc
  7.  
  8. IF1
  9.     INCLUDE    macros.mac
  10.     INCLUDE    objects.mac
  11. ENDIF
  12.  
  13.     EXTRN    findFirst:NEAR
  14.     EXTRN    getHomePath:NEAR
  15.     EXTRN    prtString:NEAR
  16.     EXTRN    sendMsg:NEAR
  17.  
  18.     EXTRN    Exec:WORD
  19.     EXTRN    FileName:WORD
  20.     EXTRN    Mouse:WORD
  21.     EXTRN    ParCmd:WORD
  22.     EXTRN    Self:WORD
  23.     EXTRN    Video:WORD
  24.  
  25.  
  26.     .CODE
  27.  
  28. IF Dbug
  29.     PUBLIC    setDEVars
  30. ENDIF
  31. COMMENT    %
  32. ==============================================================================
  33. Gets a pointer to the text string for the specified error message.
  34.  
  35. Passed:    StackTop - Error code
  36.  
  37. =============================================================================%
  38. setDEVars    PROC    NEAR
  39.     getStackArgs    ax            ;Get error code
  40.     getInst        bl,?Mouse,Mouse        ;Get mouse flag
  41.     lea        di,PgmArgs        ;Get addr of command line
  42.     mov        Bptr[di+1],al        ;Save error code there
  43.     mov        Bptr[di+2],ah
  44.     mov        Bptr[di+3],bl        ;Save mouse flag
  45.     ret
  46. setDEVars    ENDP
  47.  
  48.  
  49.  
  50. COMMENT    %
  51. ==============================================================================
  52. Gets the current path and child process name.
  53.  
  54. =============================================================================%
  55. getFilePath    PROC    NEAR
  56.     lea        di,FileName        ;Get file name buffer addr
  57.     call        getHomePath        ;Get home path
  58.     lea        si,PgmName        ;Get addr of program name
  59. gfp1:    lodsb                    ;Get a byte
  60.     mov        Bptr[di],al        ;Move byte into buffer
  61.     inc        di            ;Point to next byte
  62.     notZero        al,gfp1            ;Loop until zero encountered
  63.     mov        ParCmd,OFFSET PgmArgs    ;Set para block command tail
  64.     ret
  65. getFilePath    ENDP
  66.  
  67.  
  68.  
  69. COMMENT    %
  70. ==============================================================================
  71. Handles error by passing error code to Exec object who passes it to the 
  72. error handler program.
  73.  
  74. =============================================================================%
  75. handleError    PROC    NEAR
  76.     send        Self,Execute
  77.     ret
  78. handleError    ENDP
  79.  
  80.  
  81.  
  82. COMMENT    %
  83. ==============================================================================
  84. Looks for error handler program in current file path. If not found exits 
  85. program.
  86.  
  87. =============================================================================%
  88. ?FindErrHdlr    PROC    NEAR
  89.     lea        dx,PgmName        ;Get addr of program name
  90.     call        findFirst        ;Search for file
  91.     jnc        feh1            ;Exit if found
  92.  
  93.     send        Video,Reset        ;Reset video display
  94.     lea        si,ExitMsg        ;Get addr of msg text
  95.     xor        dx,dx            ;Cursor position
  96.     mov        bl,07h            ;Text color
  97.     call        prtString        ;Display the string
  98.     exit                    ;Exit program
  99. feh1:    ret
  100. ?FindErrHdlr    ENDP
  101.  
  102.  
  103.  
  104.     .DATA
  105.  
  106. ExitMsg        DB    "ERRDLG.EXE not found in current directory.",0
  107. PgmName        DB    "ERRDLG.EXE",0
  108. PgmArgs        DB    3,"   ",CR
  109.  
  110. defMsg    DosError,\
  111.     Error,\
  112.     <setDEVars,,handleError>
  113.  
  114. defMsg    DosError,\
  115.     Init,\
  116.     <,,?FindErrHdlr>
  117.  
  118. defMsg    DosError,\
  119.     Execute,\
  120.     <,getFilePath,>
  121.  
  122. defObj    DosError,\
  123.     <Exec>,\
  124.     <>,\
  125.     <Error,Init,Execute>
  126.  
  127.  
  128.  
  129.     END
  130.